package com.fanben100.gui.i18n;

import java.awt.LayoutManager;

import javax.swing.JPanel;

/**
 * 可切换语言Jpanel
 * 
 * @author Administrator
 * 
 */
public abstract class MultiLanguageJPanel extends JPanel implements
		LangChangeListener {
	/** 
         *  
         */
	private static final long serialVersionUID = 1L;

	/**
	 * Creates a new JPanel with the specified layout manager and buffering
	 * strategy.
	 * 
	 * @param layout
	 *            the LayoutManager to use
	 * @param isDoubleBuffered
	 *            a boolean, true for double-buffering, which uses additional
	 *            memory space to achieve fast, flicker-free updates
	 */
	public MultiLanguageJPanel(LayoutManager layout,
			boolean isDoubleBuffered) {
		super(layout, isDoubleBuffered);
		customConstruct(layout, isDoubleBuffered);
	}

	/**
	 * Create a new buffered JPanel with the specified layout manager
	 * 
	 * @param layout
	 *            the LayoutManager to use
	 */
	public MultiLanguageJPanel(LayoutManager layout) {
		super(layout);
		customConstruct(layout);
	}

	/**
	 * Creates a new <code>JPanel</code> with <code>FlowLayout</code> and the
	 * specified buffering strategy. If <code>isDoubleBuffered</code> is true,
	 * the <code>JPanel</code> will use a double buffer.
	 * 
	 * @param isDoubleBuffered
	 *            a boolean, true for double-buffering, which uses additional
	 *            memory space to achieve fast, flicker-free updates
	 */
	public MultiLanguageJPanel(boolean isDoubleBuffered) {
		super(isDoubleBuffered);
		customConstruct(isDoubleBuffered);
	}

	/**
	 * Creates a new <code>JPanel</code> with a double buffer and a flow layout.
	 */
	public MultiLanguageJPanel() {
		super();
		customConstruct();
	}

	public MultiLanguageJPanel(Object... objs) {
		super();
		customConstruct(objs);
	}

	// -----------------------------------MULTI LANGUAGE-------------------START
	private void customConstruct(Object... objs) {
		ResourceContext.getInstance().addListener(this);
		iniCurrentComponents(objs);
		updateResource();
	}

	protected String getResource(String key) {
		return ResourceContext.getInstance().getString(key);
	}

	public abstract void iniCurrentComponents(Object... objs);

	public abstract void updateResource();
	// -----------------------------------MULTI LANGUAGE-------------------END

}